1. Field of the Invention
The present invention relates in general to data processing and in particular, to methods and circuits for synchronizing streaming data and systems using the same.
2. Description of the Related Art
Under the United States high definition television (HDTV) standard (as promulgated by the Advanced Television Systems Committee), audio, video and associated control and user information are transmitted in a transport stream, for example,that defined under the MPEG2 standard. Within the stream, the video and audio data are themselves compressed into blocks, for example the video may be compressed under one of the MPEG (Motion Pictures Expert Group) formats and the audio under the Dolby AC3(copyright) (Dolby(copyright) Digital) standard. Other forms of encoding/compression may also be used, for example MPEG audio, AAC audio or MLP audio.
At the transport stream level, a Program Clock Reference (PCR) is periodically inserted in the packet stream. The PCR is a time stamp indicating the then current time with reference to a System Time Clock (STC) base against which the data was encoded into the transport stream. The PCR is used to synchronize corresponding system time clocks in the video and audio decoders.
At the decoder, disposed for example in a television unit or set-top box, the data is demultiplexed and reassembled as a packetized elementary stream (PES). In the PES layer, the audio and video data are packed into blocks along with the corresponding headers required under the specific audio and video compression standards used. The video and audio streams are then switched to the appropriate decoder.
A Presentation Time Stamp (PTS) is periodically inserted in the blocks of compressed audio and video data. The PTS indicates to the respective audio or video decoder when the following block or blocks of data are to be played to the audience. The PTS is also referenced to the STC.
Compression of audio and data is central to both the feasibility and economy of transmission of the information necessary for program dissemination in such applications as digital television and similar systems. Typically, however, decompressing compressed data is a relatively time consuming task. Moreover, decode times are not predictable and can vary significantly between the audio and video processing paths as a result of the use of diverse compression algorithms. Hence, successful use of presentation time stamps is crucial. Additionally, error concealment techniques rely on the time stamps, and therefore to insure that audio and/or video data is not lost, the time stamps and synchronized playback must be effectively used. This aids in mitigating artifacts in the presentation to the end user.
It is incumbent therefore that audio and video systems ensure fidelity playback with respect to a locally regenerated time information using the timestamps recovered from the audio and video subsystems. In sum, therefore, methods of synchronizing a data decoder with a corresponding source of encoded data are required.
A method is disclosed for synchronizing stream processing with a locally generated system time clock. A program clock reference (PCR)is recovered from a transport layer and used in varying the frequency of the locally generated system time clock. A presentation time stamp (PTS) is recovered from a packetized elementary stream (PES) derived from the transport layer. The relationship between a reference sample associated with the presentation time stamp and a current sample being streamed is determined relative to the system time clock. Samples are then added or subtracted from a stream of data samples being output to establish a relationship between the presentation time stamps and the stream of samples relative to the system time clock.
The present inventive principles allow for the efficient detection of instances where a processing device is running ahead of or behind where it should be according to a presentation time stamp. In this respect, the present inventive principles advantageously provide for the determination of both a time advantage and a sample advantage between the current data being output and a reference sample associated with the time stamp. Among other things, these principles can be applied to the synchronization of streaming audio and video data under various transport schemes and compression standards.